<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0"/>
    <meta name="format-detection" content="telephone=no,email=no,date=no,address=no">
    <title>云API</title>
    <link rel="stylesheet" type="text/css" href="../css/api.css"/>
    <link rel="stylesheet" type="text/css" href="../css/style.css"/>
    <style>

    .frame{padding: 9px; padding-right: 0px; overflow: hidden; }
     .tx{float: left; padding-right:5px; left: -60px; position: absolute;}
     .mc{  float: left; font-size: 17px; line-height: 20px; width: 75%;position: relative;;
       overflow: hidden;
       text-overflow:ellipsis;
       white-space: nowrap;  display: -webkit-box; height: 42px}
     .tx img{width: 45px;height: 45px;border-radius:6px;}
     .sj{  font-size: 12px; line-height: 20px;color: #b2b2b2;padding-right: 15px; height: 20px; position: absolute; right:60px}
     .nr{color: #9d9d9d; font-size: 12px; display: inline-block}
     .fl{float: left; border-bottom: 0.8px solid #ebebeb; height: 55px;width: 100%;  margin-left: 60px; position: relative;}
     .fl  i{display:block;
background:#f00;border-radius:50%;width:15px;height:15px;top:-5px; position:absolute;color: #ffffff;font-style:normal;right:0px;font-size: 11px;line-height:15px;
text-align: center;z-index: 1000;
       }
       .mc p img{width: 15px;height: 15px}
    </style>
</head>
<body>
  <div id="category">

</div>
<script type="text/javascript" src="../script/api.js"></script>
 <script  type="text/javascript"  src="../script/jquery-2.1.1.min.js"></script>
  <script  type="text/javascript"  src="../script/jquery.md5.js"></script>
<script type="text/javascript" src="../script/doT.min.js"></script>
<script type="text/javascript" src="../script/common.js"></script>
<script type="text/x-dot-template" id="category_template">






{{

var h=day2.getHours();
  var tm=0;
var yd=0;

ydt=0;


}}
{{~ it  : value : index }}


{{


    var   i=day2.getHours();
ydt= Math.floor(Math.random()*wd );

 tt= Math.floor(Math.random()*22);


}}


{{
if(c==index){
 s2=sj[index];
}}

<!-- <div class="frame" id="zs" tapmode onclick="openwin('qfzs')">

 <div class="fl" id="fl"> <div class="tx"><img src="../image/qf.png" height="60px" ></div>
 <div class="mc">群发助手 <br><span class="nr list_img" id="nr"> </span>  </div>
 <div class="sj" id="sj">{{=sj[index]}}</div>

</div> -->
</div>
{{

}



}}


{{

if(c>index){
   wd2=Math.floor(Math.random()*(5-1)+1 );
   zwd=zwd+wd2;

    console.log(value.title);
}}


<div class="frame">
 <div class="fl"  > <div class="tx"><img src='../image/default1.png'  srcs="{{= value.thumb }}"  class="imgCache"  height="60px" >

<i id="wd">{{=wd2}}</i>

 </div>
 <div class="mc">{{=value.title}} <br><span class="nr">{{=subString(value.url , 40, false)}}  </span>  </div>
 <div class="sj">{{=sj[index]}}</div>
</div>
</div>

{{

}else{



}}



<div class="frame" >
 <div class="fl"  > <div class="tx"><img src='../image/default1.png'  srcs="{{= value.thumb }}"  class="imgCache"  height="60px" >
{{


  if(cr1==index&&ydt>0){

    wd3=Math.floor(Math.random()*(5-1)+1 );
      cr1=Math.floor(Math.random()*30 );
zwd=zwd+wd3;

}}
<i id="wd">{{=wd3}}</i>
{{


}

console.log(value.title);
}}

 </div>
 <div class="mc">{{=value.title}}<br> <span class="nr"> {{=subString(value.url , 40, false)}}  </span>  </div>
 <div class="sj">{{=sj[index]}}</div>
</div>
</div>
{{ } }}
	{{~}}
</script>
<script type="text/javascript">
var  c=Math.floor(Math.random()*5+1);
  var wd=localStorage.getItem('wd')+c ;
  var cr1=Math.floor(Math.random()*(11-1)+3 );
var zwd=0;
 var s2;
 var sj;
function openwin(name){

  api.openWin({
      name: name,
      pageParam: {
          t: s2
},
      url: './'+name+'.html',

  });


}

function hideqf(){
    $api.css($api.byId('zs'),'display:none;');
}


function wdd(n){
  var jsfun = 'weidu('+n+');';
  api.execScript({
    name: 'root',
      script: jsfun
  });
}


  var day2 = new Date();

function sj(j){


   day1 = new Date(day2.valueOf() -j* 60 *1000);// 当前时间减掉1分钟
day1.setTime(day1.getTime());
if(day1.getMinutes()<10){
minutes="0"+day1.getMinutes()
}
else {
 minutes= day1.getMinutes()
}
i=day1.getHours()
//s2 = day2.getHours()+":" +minutes;

if(i>=0 && i<6){
    s2= "凌晨"+i+":"+minutes;
} else if(i>=6 && i<=12 ){
    s2= "上午"+i+":"+minutes;

  }else if(i>12 && i <=18){
    i=i-12;
     s2= "下午"+i+":"+minutes;
  }else if(i>18 && i<=23){
    i=i-12;
       s2= "晚上"+i+":"+minutes;
  }
  else  {
  s2= i+":"+minutes;

}

  return s2
}


function subString(str, len, hasDot) {
    var newLength = 0;
    var newStr = "";
    var chineseRegex = /[^\x00-\xff]/g;
    var singleChar = "";
    var strLength = str.replace(chineseRegex, "**").length;
    for (var i = 0; i < strLength; i++) {
        singleChar = str.charAt(i).toString();
        if (singleChar.match(chineseRegex) != null) {
            newLength += 2;
        }
        else {
            newLength++;
        }
        if (newLength > len) {
            break;
        }
        newStr += singleChar;
    }

    if (hasDot && strLength > len) {
        newStr += "...";
    }
    return newStr;
}

    apiready = function () {


      console.log( localStorage.getItem('domain') );
        // alert($api.dom('#fl').offsetWidth)
        api.ajax({
     url:localStorage.getItem('domain') ,
    method: 'get',

        },function(ret,err){
    sj=ret.sj;
          var category = $api.byId('category');
           var category_template = $api.byId('category_template');

          pagefn = doT.template(category_template.text);
            category.innerHTML = pagefn(ret.adv);

 console.log( JSON.stringify(  ret.news[0].dwz  ) )



   $api.html($api.byId('nr'),  ret.news[0].dwz );
        //    $api.html($api.byId('sj'), s2 );

 _zyzImgCache();
 imageCache();
 wdd(zwd);
        })
        api.addEventListener({
           name: 'hideqf'
       }, function(ret, err){
           if( ret ){
             hideqf();
           }
       });
    }


    function chathtml(html){

$api.prepend($api.byId('category'),html);

    }
</script>

</body>
</html>
